package com.zgkxzx.java.mutilThread.CountDownLatchTest;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Exchanger;

/**
 * 创建者   zgkxzx
 * 创建日期 2017/12/30.
 * 功能描述
 */

public class ThreadCount2 implements Runnable {
    private CountDownLatch countDownLatch;
    private Exchanger<String> exchanger;

    public ThreadCount2(CountDownLatch countDownLatch, Exchanger<String> exchanger) {
        this.countDownLatch = countDownLatch;
        this.exchanger = exchanger;
    }

    @Override
    public void run() {
        System.out.println("线程ThreadCount2开始执行，准备就绪。。。。");
        String info = "";
        try {
            info = exchanger.exchange("xxxxxx");
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程ThreadCount2开始执行，获取到信息 "+info);
        countDownLatch.countDown();

        System.out.println("线程ThreadCount2执行完成。。。。");

    }
}
